package com.android.lgc.android_mvp;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Toast;

import com.android.lgc.android_mvp.IPresenter.LoginPersenter;
import com.android.lgc.android_mvp.IView.LoginView;
import com.android.lgc.android_mvp.base.BaseActivity;
import com.android.lgc.android_mvp.ui.view.SecondActivity;
import com.kotiln.lgc.android_mvp.R;

/**
 * android mvp架构
 *
 * LoginView 为V层 也是就Activity或Fragment
 * V层持有P层的引用,V层是一个接口
 * P层持有V和M层的引用,并对两者进行关联
 * M层 逻辑处理层
 */
public class MainActivity extends BaseActivity<LoginView, LoginPersenter> implements LoginView{

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    }

    public void onBtnLogin(View v){
        getPresenter().login("admin","123456");

    }

    public void onBtnSecondAT(View v){
        startActivity(new Intent(this, SecondActivity.class));
        finish();
    }

    @Override
    public LoginPersenter createPresenter() {
        return new LoginPersenter();
    }

    @Override
    public LoginView createView() {
        return this;
    }

    @Override
    public void onLoginResult(String result) {
        Toast.makeText(this,result,Toast.LENGTH_SHORT).show();
    }

}